﻿using System;
using System.Collections.Generic;

namespace Universities
{
    public class Course
    {
        private HashSet<Student> students;

        public Course()
        {
            this.Students = new HashSet<Student>();
        }

        public HashSet<Student> Students
        {
            get
            {
                return students;
            }
            private set
            {
                students = value;
            }
        }

        public void Add(Student student)
        {
            if (students.Contains(student))
            {
                throw new ArgumentException("That student is already in the school.");
            }
            if (students.Count >= 30)
            {
                throw new ArgumentException("The course is full.");
            }
            Students.Add(student);
        }

        public bool Contains(Student student)
        {
            return students.Contains(student);
        }

        public bool Contains(int fn)
        {
            return Contains(new Student("Anonymous", fn));
        }

        public void Remove(Student student)
        {
            if (!students.Contains(student))
            {
                throw new ArgumentException("That student does not attend the course.");
            }
            students.Remove(student);
        }

        public void Remove(int fn)
        {
            Remove(new Student("Anonymous", fn));
        }
    }
}
